package dk.au.cs.peterbn.processing;

import java.util.Iterator;
import java.util.Map;

/**
 * Interface for processing that needs to be performed on a patternInstance.
 * <p/>
 * This is an instance of the Functor design pattern, used in order to move the different processing steps out in their
 * own source files.
 */
public abstract class PerInstanceProcessingJob implements ProcessingJob {

    private final Map<String, PatternInstance> patternInstances;

    public PerInstanceProcessingJob(Map<String, PatternInstance> patternInstances) {
        //To change body of created methods use File | Settings | File Templates.
        this.patternInstances = patternInstances;
    }

    public abstract void process(PatternInstance patternInstance);

    @Override
    public void process() {
        for (Iterator<String> iterator = patternInstances.keySet().iterator(); iterator.hasNext(); ) {
            String patternId = iterator.next();
            PatternInstance patternInstance = patternInstances.get(patternId);
            process(patternInstance);
        }
        //To change body of implemented methods use File | Settings | File Templates.
    }
}
